﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;

namespace Common
{
    public static class EditorLayoutHelper
    {
        public static void FileInput(string title,float titleWidth,ref string filePath)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(title,GUILayout.Width(titleWidth));
            filePath = GUILayout.TextField(filePath);
            if (GUILayout.Button("选择目录", GUILayout.Width(90)))
            {
                string directory = Application.dataPath;
                string path = EditorUtility.OpenFolderPanel("选择目录", directory, "");
                if (!string.IsNullOrEmpty(path))
                {
                    filePath = path;
                }
            }

            GUILayout.EndHorizontal();
        }

        public static string TextInput(string title,string content)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(title);
            content=GUILayout.TextField(content);
            GUILayout.EndHorizontal();
            return content;
        }

        public static Enum EnumPop(string title, Enum content)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(title);
            content = EditorGUILayout.EnumPopup(content);
            GUILayout.EndHorizontal();
            return content;
        }

        public static int Popup(string title, int selectIndex,string[] contents)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(title);
            selectIndex = EditorGUILayout.Popup(selectIndex, contents);
            GUILayout.EndHorizontal();
            return selectIndex;
        }

        //public static ReorderableList GetReorderableList()
        //{
        //    serializedObject
        //}
    }
}
